# dead -> 检测玩家是否死亡
# 选择器中 -> @a -> 无论是否存活均可检测
# 选择器中 -> @e[type=minecraft:player] -> 只会检测存活的玩家
# 死亡的玩家获得 isdead 标签
tag @a add isdead
tag @e[type=minecraft:player] remove isdead
tag @a[tag=isdead] add isdead-1
tag @a remove isdead
# 等待玩家复活后计算剩余时长
execute as @e[type=minecraft:player,tag=isdead-1] at @s run scoreboard players operation @s time_seconds /= double remagnification
execute as @e[type=minecraft:player,tag=isdead-1] at @s run scoreboard players operation @s remove_time_s = @s time_seconds
execute as @e[type=minecraft:player,tag=isdead-1] at @s run scoreboard players operation @s remove_time_m = @s time_seconds
execute as @e[type=minecraft:player,tag=isdead-1] at @s run scoreboard players operation @s remove_time_h = @s time_seconds
# 用于精确的显示时分秒
execute as @e[type=minecraft:player,tag=isdead-1] at @s run scoreboard players operation @s remove_time_s %= sixty remove_time_s
execute as @e[type=minecraft:player,tag=isdead-1] at @s run scoreboard players operation @s remove_time_m /= sixty remove_time_s
execute as @e[type=minecraft:player,tag=isdead-1] at @s run scoreboard players operation @s remove_time_h /= sixty remove_time_s
execute as @e[type=minecraft:player,tag=isdead-1] at @s run scoreboard players operation @s remove_time_h /= sixty remove_time_s
# 给玩家的提示
execute as @e[type=minecraft:player,tag=isdead-1] at @s run titleraw @s title {"rawtext":[{"text":"§l"}]}
# 如果能存储超过 1 小时的时间
execute as @e[type=minecraft:player,tag=isdead-1,scores={remove_time_s=0..9,remove_time_m=0..9,remove_time_h=1}] at @s run titleraw @s subtitle {"rawtext":[{"text":"§r§f您由于死亡而被扣除 §r§l§6"},{"score":{"name":"@s","objective":"remove_time_h"}},{"text":"§r§b 时§f， §r§l§60"},{"score":{"name":"@s","objective":"remove_time_m"}},{"text":"§r§b 分§f， §r§l§60"},{"score":{"name":"@s","objective":"remove_time_s"}},{"text":"§r§b 秒§f。"}]}
execute as @e[type=minecraft:player,tag=isdead-1,scores={remove_time_s=!0..9,remove_time_m=0..9,remove_time_h=1}] at @s run titleraw @s subtitle {"rawtext":[{"text":"§r§f您由于死亡而被扣除 §r§l§6"},{"score":{"name":"@s","objective":"remove_time_h"}},{"text":"§r§b 时§f， §r§l§60"},{"score":{"name":"@s","objective":"remove_time_m"}},{"text":"§r§b 分§f， §r§l§6"},{"score":{"name":"@s","objective":"remove_time_s"}},{"text":"§r§b 秒§f。"}]}
execute as @e[type=minecraft:player,tag=isdead-1,scores={remove_time_s=0..9,remove_time_m=!0..9,remove_time_h=1}] at @s run titleraw @s subtitle {"rawtext":[{"text":"§r§f您由于死亡而被扣除 §r§l§6"},{"score":{"name":"@s","objective":"remove_time_h"}},{"text":"§r§b 时§f， §r§l§6"},{"score":{"name":"@s","objective":"remove_time_m"}},{"text":"§r§b 分§f， §r§l§60"},{"score":{"name":"@s","objective":"remove_time_s"}},{"text":"§r§b 秒§f。"}]}
execute as @e[type=minecraft:player,tag=isdead-1,scores={remove_time_s=!0..9,remove_time_m=!0..9,remove_time_h=1}] at @s run titleraw @s subtitle {"rawtext":[{"text":"§r§f您由于死亡而被扣除 §r§l§6"},{"score":{"name":"@s","objective":"remove_time_h"}},{"text":"§r§b 时§f， §r§l§6"},{"score":{"name":"@s","objective":"remove_time_m"}},{"text":"§r§b 分§f， §r§l§6"},{"score":{"name":"@s","objective":"remove_time_s"}},{"text":"§r§b 秒§f。"}]}
# 不能够存储超过 1 小时的时间
execute as @e[type=minecraft:player,tag=isdead-1,scores={remove_time_s=0..9,remove_time_m=0..9,remove_time_h=0}] at @s run titleraw @s subtitle {"rawtext":[{"text":"§r§f您由于死亡而被扣除 §r§l§60"},{"score":{"name":"@s","objective":"remove_time_m"}},{"text":"§r§b 分§f， §r§l§60"},{"score":{"name":"@s","objective":"remove_time_s"}},{"text":"§r§b 秒§f。"}]}
execute as @e[type=minecraft:player,tag=isdead-1,scores={remove_time_s=!0..9,remove_time_m=0..9,remove_time_h=0}] at @s run titleraw @s subtitle {"rawtext":[{"text":"§r§f您由于死亡而被扣除 §r§l§60"},{"score":{"name":"@s","objective":"remove_time_m"}},{"text":"§r§b 分§f， §r§l§6"},{"score":{"name":"@s","objective":"remove_time_s"}},{"text":"§r§b 秒§f。"}]}
execute as @e[type=minecraft:player,tag=isdead-1,scores={remove_time_s=0..9,remove_time_m=!0..9,remove_time_h=0}] at @s run titleraw @s subtitle {"rawtext":[{"text":"§r§f您由于死亡而被扣除 §r§l§6"},{"score":{"name":"@s","objective":"remove_time_m"}},{"text":"§r§b 分§f， §r§l§60"},{"score":{"name":"@s","objective":"remove_time_s"}},{"text":"§r§b 秒§f。"}]}
execute as @e[type=minecraft:player,tag=isdead-1,scores={remove_time_s=!0..9,remove_time_m=!0..9,remove_time_h=0}] at @s run titleraw @s subtitle {"rawtext":[{"text":"§r§f您由于死亡而被扣除 §r§l§6"},{"score":{"name":"@s","objective":"remove_time_m"}},{"text":"§r§b 分§f， §r§l§6"},{"score":{"name":"@s","objective":"remove_time_s"}},{"text":"§r§b 秒§f。"}]}
# 死亡计数 +1
execute as @e[type=minecraft:player,tag=isdead-1] at @s run scoreboard players add @s dead_count 1 
# 删除标签
execute as @e[type=minecraft:player,tag=isdead-1] at @s run tag @s remove isdead-1